/**   
* @Description: TODO(用一句话描述该文件做什么) 
*/ 
package org.kskj.ipw.validator.handle.customized;

import java.lang.annotation.Annotation;
import java.util.regex.Pattern;

import org.kskj.ipw.exception.ValidateException;
import org.kskj.ipw.validator.annotation.IsDigit;
import org.kskj.ipw.validator.handle.ValidatorHandle;

/** 
* @author sztan 
* @date 2016年8月9日 下午5:34:28 
* @version 1.0 
*/
public class IsDigitValidatorCustomizedHandle implements ValidatorHandle {

	@Override
	public void validate(Annotation annotation, Object parameterValue) throws ValidateException {
		String message = ((IsDigit)annotation).message();
		String value = (String)parameterValue;
		String patternStr = "\\d*";
		Pattern pattern = Pattern.compile(patternStr);
		if (value != null && !"".equals(value)) {
			if (!pattern.matcher(value).matches()) {
				throw new ValidateException(message + " IsDigitValidatorCustomizedHandle The value is:" + value);
			}
		}
	}

}
